﻿<html>
  <head>
    <meta name="GENERATOR" content="BLOCKNOTE.NET"/>
    <meta name="source"/>
    <basefont face="Verdana" size="2"/>
    <meta name="generator" content="h-smile:richtext"/>
  </head>
<body>
  <h1>Array object</h1>
  <p>Represents indexed vector (array) of values.</p>
  <div align="left">
    <table border="0" cellpadding="4" cellspacing="0" width="100%">
      <tr>
        <td colspan="2">
          <h2>Properties</h2></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>length</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">- <em>integer</em>, number of items in the array. Read/write property.</td></tr>
      <tr>
        <td width="117" bgcolor="#ffffff" valign="top" align="right"><strong><em>[index]</em></strong></td>
        <td bgcolor="#fffff0" valign="middle"><strong>- </strong><em>value</em>, element of the array at the <em>index</em> position, Read-write index accessor. Zero-based index.</td></tr>
      <tr>
        <td width="117" bgcolor="#ffffff" valign="top" align="right"><strong><em>[begin..end]</em></strong></td>
        <td bgcolor="#fffff0" valign="middle"><strong>- </strong><em>integers</em>, zero-based indexes of first and last element of the range. Returns slice of vector contains elements from <em>start</em> index and up to but not included <em>end</em> index. <em>Begin</em> or/and <em>end</em> are optional. If begin is ommited then it is assumed to be 0, if end - <em>length</em> is used as an end value.</td></tr>
      <tr>
        <td colspan="2" valign="top">
          <h2>Methods</h2></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>Array</em></strong></td>
        <td bgcolor="#fffff0" valign="top"><strong>([value1 [, value2 [, ... valueN ]]])</strong>
          <p>Creates new array object from arguments provided. Use as <br/>var a = new Array(...);</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>toLocaleString</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>()</strong> returns: string</div>
          <p>Returns string - comma separated list of values</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>toString</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>()</strong> returns: string</div>
          <p>Returns string - comma separated list of values</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>valueOf</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>()</strong> returns: string</div>
          <p>Same as <em>toString</em>.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>clone</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>() </strong>returns: array</div>
          <p>Returns brand new copy of the array.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>push</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>([value1 [, value2 [, ... valueN ]]])</strong> returns: value</div>
          <p>Appends array by <em>values</em>. Returns last inserted element.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>shift</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>()</strong> returns: value | undefined</div>
          <p>Removes first element of the array. Returns removed element.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>pop</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>()</strong> returns: value | undefined</div>
          <p>Removes last element of the array. Returns removed element.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>unshift</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>(value)</strong> returns: value | undefined</div>
          <p>Inserts value at first array position. Returns the value.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>concat</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>([value1 [, value2 [, ... valueN ]]]) </strong>returns: array</div>
          <p>Appends array by <em>values</em>. Returns the array.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>join</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>([delimeter])</strong> returns: string</div>
          <p>Returns string with all elements of the array separated by the <em>delimeter</em> or comma</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>reverse</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>()</strong> returns: array</div>
          <p>Reverses order of elements in the array in-place. Returns the array.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>slice</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>(start[, end])</strong> returns: array | undefined</div>
          <p>Returns new array consisting from elements of the array from <em>start</em> up to but not including <em>end</em> index.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>splice</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>(start[, end])</strong> returns: array | undefined</div>
          <p>Moves range of elements from <em>start</em> to <em>end</em> (not including) from the array into new array and returns this new array.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>sort</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>( [compareFunction] )</strong> returns: array</div>
          <p>Sorts elements of the array in ascending order. If the <em>compareFunction</em> provided it is used for comparing elements during sort. &nbsp;<em>compareFunction</em> shall accept two values in parameters and return -1, 0 or +1 as a result.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>indexOf</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>( </strong><em>value</em> [, <em>notfound</em> = -1] <strong>)</strong> returns: int | <em>notfound</em></div>
          <p>Get index of the <em>value</em> in array. If the <em>value</em> is not found returns the <em>notfound</em> value (-1 by default).</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>lastIndexOf</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>( </strong><em>value</em> [, <em>notfound</em> = -1] <strong>)</strong> returns: int | <em>notfound</em></div>
          <p>Get last index of the <em>value</em> in array. If the <em>value</em> is not found returns the <em>notfound</em> value (-1 by default).</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>remove</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>( </strong><em>index</em>:int <strong>) </strong>returns: value | nothing</div>
          <p>Removes element at <em>index</em>. Returns removed element.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>removeByValue</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>( </strong><em>value</em> <strong>) </strong>returns: value | nothing</div>
          <p>Tries to locate element by value in the array and removes it. Returns removed element.</p></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>map</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <div><strong>(</strong> <em>callback</em>: function [, <em>thisObject</em>] <strong>)</strong> : array</div>
          <p>This method creates a new array with the result of calling a provided <em>callback</em> function on every element in this array. If <em>thisObject</em> is provided then the callback will have it as <em>this</em>.</p>
          <p>The callback function may accept following parameters: <code>callback(currentValue, index, array)</code> where:</p>
          <ul>
            <li><em>currentValue</em> is a value of array element at the <em>index</em> position;</li>
            <li><em>array</em> is the array to what this method applied.</li></ul>
          <p>The <em>map</em> method<span class="Apple-converted-space"> </span>does not mutate the array on which it is called.</p>
          <p>If the callback function ends with nothing (without explicit return) then the element will not go to resulting array (as when filter() method below returns false). Note: this a la filter() behavior is non standard.</p>
          <p>Example:</p>
          <pre>var numbers = [1, 2, 3];
var squares = numbers.map(:el:el*el); // make new array of 
                                      // squares of numbers 
                                      // in original array.
// squares will be [1, 4, 9] at this point.
</pre></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>reduce</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <p><strong>(</strong> callback:function [, initialValue] <strong>)</strong> : value</p>
          <p>This method applies the function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value.</p>
          <p>The callback function may accept following parameters: <code>callback(previousValue, currentValue, index, array)</code> where:</p>
          <ul>
            <li><em>previousValue</em> is either <em>initialValue</em> (on first run) or result of previous call of the callback function;</li>
            <li><em>currentValue</em> is a value of array element at the <em>index</em> position;</li>
            <li><em>array</em> is the array being scanned (reduced).</li></ul>
          <p>The method returns result of last <em>callback</em> invocation. The method<span class="Apple-converted-space"> </span>does not mutate the array on which it is called.</p>
          <p>Example, this fragment calculates sum of all elements in the array:</p>
          <pre>var total = [0, 1, 2, 3].reduce( :a, b: a + b );
// total is 6 at this point.
</pre></td></tr>
      <tr>
        <td bgcolor="#ffffff" valign="top" align="right"><strong><em>filter</em></strong></td>
        <td bgcolor="#fffff0" valign="middle">
          <p><strong>(</strong> <em>callback</em>: function [, <em>thisObject</em>] <strong>)</strong> : array</p>
          <p>This method calls the <em>callback</em><span class="Apple-converted-space"> </span>function once for each element in the array, and constructs new array of all the values for which<span class="Apple-converted-space"> </span>the <em>callback</em> returns <em>true</em>.</p>The callback function may accept following parameters: <code>callback(currentValue, index, array)</code> where:
          <ul>
            <li><em>currentValue</em> is a value of array element at the <em>index</em> position;</li>
            <li><em>array</em> is the array to what this method applied.</li></ul>
          <p>The <em>filter</em> method<span class="Apple-converted-space"> </span>does not mutate the array on which it is called.</p>
          <p>Example, this code creates new array from elements of source array that are greater than 10:</p>
          <pre>var filtered = [12, 5, 8, 130, 44].filter(:el: el > 10);
// filtered is [12, 130, 44] here
</pre></td></tr></table></div>
</body>
</html>